package com.sgb.kjwl.pop;

import android.content.Context;

import androidx.recyclerview.widget.GridLayoutManager;

import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.supplier3.DictEntity3;
import com.sgb.kjwl.view.ui.adapter.carrierDemand.DemandHallListAdapter;
import com.sgb.kjwl.view.widget.MaxHeightRecyclerView;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;
import com.swgk.core.recyclerview.adapter.AdapterOnItemClick;

import java.util.List;

public class CommodityMaterialsPopWindow extends BasePopWindow {

    private DemandHallListAdapter demandhalllistadapter;

    public CommodityMaterialsPopWindow(Context context) {
        super(context);
    }

    @Override
    protected int popLayout() {
        return R.layout.popwindow_goods_types;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        MaxHeightRecyclerView recyclerView = holder.getPop().findViewById(R.id.type_list);
        demandhalllistadapter = new DemandHallListAdapter(mContext, null);
        demandhalllistadapter.setItemSelect(true);
        demandhalllistadapter.setDefItem(-1);
        recyclerView.setLayoutManager(new GridLayoutManager(mContext, 4));
        recyclerView.setAdapter(demandhalllistadapter);
        demandhalllistadapter.setOnItemClick(new AdapterOnItemClick<DictEntity3>() {
            @Override
            public void onItemClick(DictEntity3 provinceEntity, int position) {
                onResultClick.result(provinceEntity, position, null);
                dissMiss();
            }
        });
    }

    public void setData(List<DictEntity3> dictdata, int currentTab) {
        demandhalllistadapter.setDatas(dictdata);
        demandhalllistadapter.setDefItem(currentTab);
    }

    public void setDefItem(int position) {
        demandhalllistadapter.setDefItem(position);
    }
}
